<?php 
	
class AdminModify
{

	var $pdo = null;
    var $logger = null;
    function __construct()
    {
        $this->pdo = PDOWrapper::instance();
        $this->logger = CLog::getInstance();
    }
	

    /**
     * @param $GetParams
     * @param $PostArray
     * @return bool
     * 修改管理员权限
     */
    function ModifyAuth($PostArray){

        if(!isset($PostArray['status'])){
            Utils::ShowError(ErrorDefine::REQUIRED_FIELD_EMPTY);
            return false;
        }
        if(empty($PostArray['dept_id'])){
            Utils::ShowError(ErrorDefine::REQUIRED_FIELD_EMPTY);
            return false;
        }
        if($PostArray['dept_id'] == 1000) {
            Utils::ShowError(ErrorDefine::INVALID_BUSINESS_TYPE);
            return false;
        }
        if(empty($PostArray['type'])){
            Utils::ShowError(ErrorDefine::REQUIRED_FIELD_EMPTY);
            return false;
        }
        $param = [
            'func_name' => $PostArray['type']
        ];
        $field = ['func_id'];
        $func_id = $this->pdo->select('function',$field,$param);
        $func_id = $func_id[0]['func_id'];
        $auth_id = $func_id + $PostArray['dept_id'];
        $param = [
            'auth' => $PostArray['status']
        ];
        $where = [
            'auth_id' =>$auth_id
        ];
        $ret = $this->pdo->update('auth',$param,$where);
        if(empty($ret)){
            Utils::ShowError('408','更新后再操作');
            return false;
        }
        
        return $ret;
    }

    function ModifyDepartment($PostArray){

        if(empty($PostArray['dept_id'])){
            Utils::ShowError(ErrorDefine::REQUIRED_FIELD_EMPTY);
            return false;
        }
        if(empty($PostArray['dept_name'])){
            Utils::ShowError(ErrorDefine::REQUIRED_FIELD_EMPTY);
            return false;
        }
        $param = [
            'dept_name' => $PostArray['dept_name']
        ];
        $where = [
            'dept_id' => $PostArray['dept_id']
        ];
        $ret = $this->pdo->select('department',null,$where);
        if(empty($ret)){
            Utils::ShowError(ErrorDefine::DATABASE_ERROR);
            return false;
        }
        
        $ret = $this->pdo->update('department',$param,$where);
        return $ret;
    }


    

}